package top.jiachunlei.chain;

/**
 * 创建抽象的记录器类
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/12/10 23:10
 */
public abstract class AbstractLogger
{
    public static int INFO = 1;
    public static int DEBUG = 2;
    public static int ERROR = 3;

    protected int level;
    protected AbstractLogger logger;

    //设置继任者
    public void setLogger(AbstractLogger logger)
    {
        this.logger = logger;
    }

    public void logMessage(int level,String msg){
        if(this.level <= level){
            write(msg);
        }
        if(logger != null){
            logger.logMessage(level, msg);
        }
    }

    //处理请求
    abstract protected void write(String message);
}
